<style type="text/css">
/*CATEGORY WIDGET START HERE*/

ul.exam_browse_category li {
border-bottom-widht:1px;
border-bottom-style:solid;
}

ul.exam_browse_category li + li {
padding:0;
border:none;
}

ul.exam_browse_category li .cat {
border-bottom-width:1px;
border-bottom-style:solid;
padding:5px;
}

ul.exam_browse_category li img.icon {
float:left;
margin-top:1px;
margin-right:5px;
}

ul.exam_browse_category li .subcat {
clear:both;
overflow:hidden;
padding:0;
margin-left:21px;
}

ul.exam_browse_category li .subcat a {
clear:both;
border-bottom-width:1px;
border-bottom-style:solid;
padding:5px;
display:block;
}

ul.exam_browse_category li .cat:hover,ul.exam_browse_category li .subcat a:hover {
background-image:url(../images/transparent_bg.png);
text-decoration:none;
}

</style>
<script type="text/javascript">
	var formsubmit = 0;
	var categoryAction =function(category,subcategory, catgeoryname) 
	{
		formsubmit = '<?php echo $this->formsubmit ?>';
		if($('category')){
		  $('category').value = category;
		}
 		if($('categoryname')){
	  	$('categoryname').value = catgeoryname;
 		}
 		if($('subcategory')){
	    $('subcategory').value = 0;
 		}
 		if($('subcategoryname')){
	    $('subcategoryname').value = 0;
 		}
 		if(formsubmit == 0) {
 			window.location.href= en4.core.baseUrl+'exams/index?category=' + category +'&subcategory=' + subcategory;
 		} 
 		else {
 			 $('filter_form').submit();	  	
 		}		
	}
 	var subcategoryAction = function(category,subcategory,categoryname,subcategoryname) 
 	{
 		formsubmit = '<?php echo $this->formsubmit ?>';
 		if($('category')){
	  	$('category').value = category;
 		}
 		if($('categoryname')){
	  	$('categoryname').value = categoryname;
 		}
 		if($('subcategory')){
	    $('subcategory').value = subcategory;
 		}
 		if($('subcategoryname')){
	    $('subcategoryname').value = subcategoryname;
 		}
 		if(formsubmit == 0) {
 			window.location.href= en4.core.baseUrl+'exams/index?category=' + category +'&subcategory=' + subcategory;
 		} 
 		else {
 			 $('filter_form').submit();	  	
 		}
	}


function show_subcat(cat_id) {
		
	if(document.getElementById('subcat_' + cat_id)) {
		if(document.getElementById('subcat_' + cat_id).style.display == 'block') {
		
			document.getElementById('subcat_' + cat_id).style.display = 'none';
			document.getElementById('img_' + cat_id).src = './application/modules/Exam/externals/images/plus.gif';
		} else if(document.getElementById('subcat_' + cat_id).style.display == '') {
			
			document.getElementById('subcat_' + cat_id).style.display = 'none';
			document.getElementById('img_' + cat_id).src = './application/modules/Exam/externals/images/plus.gif';
		}
		else {
			
			document.getElementById('subcat_' + cat_id).style.display = 'block';
			document.getElementById('img_' + cat_id).src = './application/modules/Exam/externals/images/minus.gif';
		}
		
	}
}
</script> 
<?php if (count($this->categories1)): ?>
	<ul class="exam_browse_category seaddons_sidebar_exam">
		<li>
			<a href="javascript:subcategoryAction(0,0,0,0)" <?php if($this->category==0):?>class="bold"<?php endif;?>><?php echo $this->translate("All Categories") ?></a>
		</li>		
        
	  <?php foreach($this->categories1 as $category) : ?>
	        
			<?php $total_subcat = count($category['sub_categories']); ?>
            
			<?php if($total_subcat > 0):  ?>
				<li>
					<div class="cat" >
						<a href="javascript:show_subcat('<?php echo $category['category_id'] ?>')" id='button_<?php echo $category['category_id']?>'>
						<?php if($this->category != $category['category_id']): ?>
							<img src='./application/modules/Exam/externals/images/plus.gif' class='icon' border='0' id='img_<?php echo $category['category_id'] ?>'/>
							
							<?php elseif($this->subcategories != 0 &&  $this->category == $category['category_id']): ?>
							<img src='./application/modules/Exam/externals/images/minus.gif' class='icon' border='0' id='img_<?php echo $category['category_id'] ?>'/>
							<?php elseif($this->category != 0 &&  $this->category == $category['category_id']): ?>
							<img src='./application/modules/Exam/externals/images/plus.gif' class='icon' border='0' id='img_<?php echo $category['category_id'] ?>'/>
						</a>
						<?php endif;?>
						<a>
							<?php echo $this->translate($category['category_name']) ?>
						</a>
					</div>	
					<div class="subcat" id="subcat_<?php echo $category['category_id']?>" <?php if($this->category != $category['category_id'] || $this->subcategories ==0): ?>style="display:none;"<?php endif;?> >
					
						<?php foreach($category['sub_categories'] as $subcategory) : ?>						
							<a>
								<?php echo $this->translate($subcategory['sub_cat_name']) ?>
							</a>
						<?php endforeach; ?>
				 	</div>
				</li>			 	
			<?php elseif($category['parent_id'] = 0):?>
				<li>
					<div class="cat">							   
    					<img  src="./application/modules/Exam/externals/images/minus_disabled.gif" class='icon' border="0" />
    			  		<a><?php echo $this->translate($category['category_name']) ?></a> 			  		
		  		      </div>
		  	   </li>	
			<?php endif; ?>
	 	<?php endforeach; ?>
 	</ul>
<?php endif; ?>
